// ast.h
typedef enum {
    NUM_NODE,
    FLOAT_NODE,
    VAR_NODE,
    OP_NODE,
    PRINT_NODE,
    IF_NODE,
    FUNCTION_NODE
} NodeType;

typedef struct ASTNode {
    NodeType type;
    union {
        int num;
        double fnum;
        char *var_name;
        struct {
            char op;
            struct ASTNode *left;
            struct ASTNode *right;
        } op;
        struct ASTNode *expr;
        struct {
            struct ASTNode *cond;
            struct ASTNode *then_branch;
            struct ASTNode *else_branch;
        } if_stmt;
        struct {
            char *name;
            struct ASTNode *body;
        } function;
    };
} ASTNode;

ASTNode *create_num_node(int num);
ASTNode *create_float_node(double fnum);
ASTNode *create_var_node(char *name);
ASTNode *create_op_node(char op, ASTNode *left, ASTNode *right);
ASTNode *create_print_node(ASTNode *expr);
ASTNode *create_if_else_node(ASTNode *cond, ASTNode *then_branch, ASTNode *else_branch);
ASTNode *create_function_node(char *name, ASTNode *body);
void free_ast(ASTNode *node);